package com.ck.ckcloud.networkmanagement.domain.aggregate;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ck.ckcloud.common.core.util.R;
import com.ck.ckcloud.networkmanagement.domain.entity.Resource;
import lombok.Data;

/**
 * 网管聚合根
 * (一条监测记录)
 * @author Aiden <a href="mailto:adam602260@gmail.com"/>
 * @version NetworkManagement.java v0.1
 * @create 2019-09-18 17:12
 */
@Data
public class NetworkManagement {

	/**
	 * 网管资源
	 */
	private Resource resource;

	public NetworkManagement(Resource resource){
		this.resource = resource;
	}

	/**
	 * 根据uniqueId获取监测记录中的资源信息
	 * @param uniqueId
	 * @return
	 */
	public Resource getResourceByUniqueId(String uniqueId){
		return resource.getByUniqueId(uniqueId);
	}

	/**
	 * 分页查询资源
	 * @param page
	 * @return
	 */
	public R getResourceByPage(Page page){
		IPage iPage = resource.getResourceRepository().page(page);
		return new R<>(iPage);
	}
}
